package ict.kth.se.model.repository;

import ict.kth.se.exceptions.EntityAlreadyExistsInDBException;
import ict.kth.se.exceptions.EntityDoesntExistInDBException;
import ict.kth.se.model.Person;
import ict.kth.se.model.Role;

import java.sql.SQLException;
import java.util.List;

public interface RoleRepository {

	/**
	 * Get Role by id
	 * @param id Id of role
	 * @return Found role
	 */
	public Role getRoleById(Long id) throws SQLException;
	
	/**
	 * Get Role by name
	 * @param name Name of role
	 * @return Found role
	 */
	public Role getRoleByName(String name) throws SQLException;
	
	/**
	 * Get all role
	 * @return Found roles
	 */
	public List<Role> getAllRoles() throws SQLException;
	
	/**
	 * This method removes one role from database (by it's ID)
	 * @param role The role to be removed
	 * @throws EntityDoesntExistInDBException If role doesn't exist in database
	 * @throws SQLException
	 */
	public void removeRole(Role role) throws EntityDoesntExistInDBException, SQLException;
	
	/**
	 * This method adds an role in DB
	 * @param role Role to be added
	 * @return Newly created role
	 * @throws EntityAlreadyExistsInDBException If such role already exists in DB (by name)
	 * @throws SQLException
	 */
	public Role createRole(Role role) throws EntityAlreadyExistsInDBException, SQLException;
	
	/**
	 * This method updates an role in DB
	 * @param role Role to be updated
	 * @throws EntityDoesntExistInDBException If such role doesn't exist in DB (by id)
	 * @throws SQLException
	 */
	public void updateRole(Role role) throws EntityDoesntExistInDBException, SQLException;
}
